package com.wuyoucar.controller;

import com.wuyoucar.common.ResultBean;
import com.wuyoucar.service.OrderService;
import org.bouncycastle.cms.PasswordRecipientId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.LinkedHashMap;

@RestController
@RequestMapping("/consumer")
public class OrderController {

    @Autowired
    private OrderService orderService;

    //这是查询根据用户id查询该用户的所有订单
    @RequestMapping("/findAllOrders/{userid}")
    public ResultBean getAllOrders(@PathVariable("userid") Integer userid) throws ParseException{
        return orderService.getAllOrders(userid);
    }
    //根据ordernumber移除订单
    @RequestMapping("/cancelOrderByOrdernumber/{ordernumber}")
    public ResultBean cancelOrderByOrderid(@PathVariable("ordernumber") String ordernumber){
        return orderService.cancelOrderByOrderid(ordernumber);
    }

    //支付订单
    @RequestMapping("/payOrder/{ordernumber}")
    public ResultBean payOrderByOrder(@PathVariable("ordernumber") String ordernumber){
        return orderService.payOrderByOrder(ordernumber);
    }

}
